
let  express = require('express');
let  bodyParser = require('body-parser');

//1 创建服务器
let  webServer = express();

//2 urlencoded解析器
let  urlenParser = bodyParser.urlencoded({extended:true});

//3 json解析器
let jsonParser = bodyParser.json();

//4 中间件拦截处理对应路径的请求
webServer.use('/home',urlenParser);
webServer.use('/discover',jsonParser);

//对应路径post请求
webServer.post('/home',function(res,rep){
    console.log('urlencoded格式解析请求');
    console.log(res.body);
    rep.send('hello world');
    

});

webServer.post('/discover',function(res,rep){
    console.log('json格式解析请求');
    console.log(res.body);
    rep.send('hello world');
    

});

webServer.listen(8080);


